/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upn.sigemfi.vfi.be;

import edu.upn.sigemfi.plt.be.Cuenta;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

/**
 *
 * @author Programador
 */
@Entity
@Table(name = "VFI_TRAN_FINANCIERA")
@PrimaryKeyJoinColumn(name = "ID_TRANSACCION", referencedColumnName = "ID_TRANSACCION")
@DiscriminatorValue(value = "TRF")
@NamedQueries({@NamedQuery(name = "TranFinanciera.findAll", query = "SELECT t FROM TranFinanciera t"), @NamedQuery(name = "TranFinanciera.findByIdTransaccion", query = "SELECT t FROM TranFinanciera t WHERE t.idTransaccion = :idTransaccion")})
public class TranFinanciera
        extends Transaccion
        implements Serializable {

    private static final long serialVersionUID = 1L;
//    @Id
//    @Basic(optional = false)
//    @Column(name = "ID_TRANSACCION", nullable = false)
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    private Long idTransaccion;
    @JoinColumn(name = "FID_PLT_CHEQUE", referencedColumnName = "ID_CHEQUE", nullable = true)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Cheque fidPltCheque;
    //Join
    @JoinColumn(name = "FID_VFI_PAGO_CREDITO", referencedColumnName = "ID_PAGO_CREDITO")
    @ManyToOne(fetch = FetchType.LAZY)
     private PagoCredito fidVfiPagoCredito;
//    @JoinColumn(name = "ID_TRANSACCION", referencedColumnName = "ID_TRANSACCION", nullable = true, insertable = false, updatable = false)
//    @OneToOne(optional = false, fetch = FetchType.LAZY)
//    private Transaccion transaccion;
    @JoinColumn(name = "FID_SEG_USUARIO_VENTANILLA", referencedColumnName = "ID_USUARIO_VENTANILLA", nullable = true)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private UsuarioVentanilla fidSegUsuarioVentanilla;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fidVfiTransaccion", fetch = FetchType.LAZY)
    private List<DetalleTransaccion> detalleTransaccionList;
    @JoinColumn(name = "FID_PLT_CUENTA", referencedColumnName = "ID_CUENTA")
    @ManyToOne(fetch = FetchType.LAZY)
    private Cuenta fidPltCuenta;

    public TranFinanciera() {
    }

    public TranFinanciera(Long idTransaccion, Cuenta fidPltCuenta) {

        // this.idTransaccion = idTransaccion;
        super(idTransaccion);
        this.fidPltCuenta = fidPltCuenta;
    }

//    public TranFinanciera(Long idTransaccion, Cuenta fidPltCuenta) {
//        super(idTransaccion);
//        this.fidPltCuenta = fidPltCuenta;
//    }
//    public Long getIdTransaccion() {
//        return idTransaccion;
//    }
//
//    public void setIdTransaccion(Long idTransaccion) {
//        this.idTransaccion = idTransaccion;
//    }
    public Cheque getFidPltCheque() {
        return fidPltCheque;
    }

    public void setFidPltCheque(Cheque fidPltCheque) {
        this.fidPltCheque = fidPltCheque;
    }



//    public Transaccion getTransaccion() {
//        return transaccion;
//    }
//
//    public void setTransaccion(Transaccion transaccion) {
//        this.transaccion = transaccion;
//    }
    public UsuarioVentanilla getFidSegUsuarioVentanilla() {
        return fidSegUsuarioVentanilla;
    }

    public void setFidSegUsuarioVentanilla(UsuarioVentanilla fidSegUsuarioVentanilla) {
        this.fidSegUsuarioVentanilla = fidSegUsuarioVentanilla;
    }

    public List<DetalleTransaccion> getDetalleTransaccionList() {
        return detalleTransaccionList;
    }

    public void setDetalleTransaccionList(List<DetalleTransaccion> detalleTransaccionList) {
        this.detalleTransaccionList = detalleTransaccionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTransaccion != null ? idTransaccion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transaccion)) {
            return false;
        }
        Transaccion other = (Transaccion) object;
        if ((this.idTransaccion == null && other.idTransaccion != null) || (this.idTransaccion != null && !this.idTransaccion.equals(other.idTransaccion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.vfi.be.TranFinanciera[idTransaccion=" + idTransaccion + "]";
    }

    /**
     * @return the fidPltCuenta
     */
    public Cuenta getFidPltCuenta() {
        return fidPltCuenta;
    }

    /**
     * @param fidPltCuenta the fidPltCuenta to set
     */
    public void setFidPltCuenta(Cuenta fidPltCuenta) {
        this.fidPltCuenta = fidPltCuenta;
    }

    /**
     * @return the fidVfiPagoCredito
     */
    public PagoCredito getFidVfiPagoCredito() {
        return fidVfiPagoCredito;
    }

    /**
     * @param fidVfiPagoCredito the fidVfiPagoCredito to set
     */
    public void setFidVfiPagoCredito(PagoCredito fidVfiPagoCredito) {
        this.fidVfiPagoCredito = fidVfiPagoCredito;
    }
}
